<?php
declare (strict_types = 1);

namespace app\controller;

use app\common\model\Article;
use app\common\model\ArticleCate;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class AdminSetting extends AdminInit
{
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        View::assign("title","文章列表");
        return  view();
    }

    public function baidu()
    {
        if(request()->isPost()){
            $arr = input("post.");
            //将数组写入配置文件
            $a = var_export($arr,true);
            $res = file_put_contents(app()->getRootPath()."/config/baiduzhanzhang.php","<?php \n return ".$a.';');

            if($res){
                return  json(["code"=>200,"msg"=>"成功"]);
            }else{
                return  json(["code"=>4000,"msg"=>"请稍后再试"]);
            }
        }
        View::assign("title","文章列表");
        return  view();
    }

    public function baijiahao()
    {
        return  view();
    }




    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {

        $arr = input("post.");
        //将数组写入配置文件
        $a = var_export($arr,true);
        $res = file_put_contents(app()->getRootPath()."/config/web.php","<?php \n return ".$a.';');

        if($res){
            return  json(["code"=>200,"msg"=>"成功"]);
        }else{
            return  json(["code"=>4000,"msg"=>"请稍后再试"]);
        }
    }



}
